/*
 * @Author: 梁青春
 * @Date: 2022-04-22 08:46:06
 * @LastEditTime: 2022-04-24 10:23:05
 * @LastEditors: 梁青春
 */
import { createRouter, createWebHashHistory } from "vue-router";
// import VueCookies from 'vue-cookies'
// import http from '@/utils/httpRequest'
const routes = [
  {
    path: '/',
    component: () => import ('@/views/main.vue'),
    name: 'main',
    hidden: true,
    children: [
      
    ]
  },
  {
    path: '/login',
    component: () => import ('@/views/common/login.vue'),
    name: 'login',
    hidden: true
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  linkActiveClass:'active', 
  scrollBehavior: () => ({ y: 0 }),
  routes: routes
});
//路由守卫
router.beforeEach((to, from, next) => {
// const token = VueCookies.get('token')
// const role = localStorage.getItem('ms_username');
// NProgress.start(); //进度条
// http({
//     url: http.adornUrl('/sys/menu/nav'),
//     method: 'get',
//     params: http.adornParams()
//     }).then(({data}) => {
//     if (data && data.code === 0) {
//         sessionStorage.setItem('permissions', JSON.stringify(data.permissions || '[]'))
//     } else {
//         sessionStorage.setItem('permissions', '[]')
//     }
// }).catch((e) => {
//     console.log(`%c${e} 请求菜单列表和权限失败，跳转至登录页！！`, 'color:blue')
//     router.push({ name: 'guide' })
// })
// if (to.path !== '/login' && !token) {
//     next('/login');
// } else {
//     if (to.name === 'Login' && token) {
//         router.push('/')
//     } else {
//         next();
//     }
// }
next();
});
export default router;